package demo.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class JDKInvocationHandler implements InvocationHandler {

    private Object target;  //目标对象

    public JDKInvocationHandler(Object target){
        this.target = target;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("代理，执行代理");
        //通过反射，调用目标对象的方法
        method.invoke(target, args);
        return null;
    }
}
